package com.dunqi.gpm.shunqing.home.widget;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.dunqi.gpm.shunqing.R;
import com.dunqi.gpm.shunqing.common.base.CommonAdapter;
import com.dunqi.gpm.shunqing.common.base.CommonViewHolder;
import com.dunqi.gpm.shunqing.home.constance.Constance;

import java.util.Arrays;

/**
 * Created by Administrator on 2017/11/25.
 */

public class ProjectTimeLineHeader extends FrameLayout {

    private GridView gridView;
    static String[] types = {"基本信息", "项目简介", "年度计划", "前期信息", "项目进度",
            "项目动态","问题协调", "项目监控"
    };
    int[] icons = Constance.PROJECT_DETAIL_TITLE_ICON;

    public ProjectTimeLineHeader(@NonNull Context context) {
        this(context, null);
    }

    public ProjectTimeLineHeader(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);

        LayoutInflater.from(context).inflate(R.layout.no_grid_view, this);
        gridView = findViewById(R.id.no_grid_view);

        gridView.setAdapter(new CommonAdapter<String>(context, Arrays.asList(types)) {
            @Override
            public int getLayout(int position) {
                return R.layout.item_project_detail_head;
            }

            @Override
            public void bindData(CommonViewHolder cvh, int position) {
                cvh.setText(R.id.des_tv, getItem(position));
                ImageView image_iv = cvh.getView(R.id.image_iv);
                Glide.with(context).load(icons[position]).into(image_iv);
            }
        });
    }


    public GridView getGridView() {
        return gridView;
    }
}
